package com.example.ApiController;

import com.example.common.Result;
import com.example.entity.Score;
import com.example.entity.Student;
import com.example.service.ScoreService;
import com.example.service.StudentService;
import com.example.utils.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/score")
public class ScorepApiController {

    @Autowired
    private ScoreService scoreService;
    @Autowired
    private StudentService studentService;


    /**
     * 根据教师id查询所带学生的成绩统计
     */
    @RequestMapping("/getScoreCount")
    public Result getScoreCount(Integer teacherId) {
        List<Map<String,String>> list = scoreService.getScoreCount(teacherId);
        return Result.success(list);
    }
    /**
     * 根据学生id查询所在班级所有学生的成绩
     */
    @RequestMapping("/getScoreByMonitorId")
    public Result getScoreByMonitorId(Integer monitorId) {
        List<Map<String,String>> list = scoreService.getScoreByMonitorId(monitorId);
        return Result.success(list);
    }
    /**
     * 根据学生id查询自己的成绩
     */
    @RequestMapping("/getScoreByStudentId")
    public Result getScoreByStudentId(Integer studentId) {
        Student student = studentService.selectById(studentId);
        Integer classId = student.getClassId();
        List<Map<String,String>> list = scoreService.getScoreByStudentId(studentId);
        return Result.success(list);
    }



}
